package com.xiangban.controller;

import com.xiangban.aop.Permission;
import com.xiangban.model.res.ApiResult;
import com.xiangban.service.FrontPageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/12/28 9:00
 */
@RestController
@RequestMapping("/frontPage")
public class FrontPageController {

    @Autowired
    private FrontPageService frontPageService;


    @RequestMapping("/variousData")
    @ApiOperation("顶部栏数据")
    @Permission(permission = "admin:frontPage:variousData")
    public ApiResult<Object> variousData(){
        return ApiResult.newSuccess(frontPageService.variousData());
    }

    @RequestMapping("/ageStatistics")
    @ApiOperation("年龄分布统计(饼图)")
    @Permission(permission = "admin:frontPage:ageStatistics")
    public ApiResult<Object> ageStatistics(){
        return ApiResult.newSuccess(frontPageService.ageStatistics());
    }

    @RequestMapping("/relationSource")
    @ApiOperation("用户来源分布(饼图)")
    @Permission(permission = "admin:frontPage:relationSource")
    public ApiResult<Object> relationSource(){
        return ApiResult.newSuccess(frontPageService.relationSource());
    }

    @RequestMapping("/relationOrderRanking")
    @ApiOperation("用户订单排行榜(柱状图)")
    @Permission(permission = "admin:frontPage:relationOrderRanking")
    public ApiResult<Object> relationOrderRanking(){
        return ApiResult.newSuccess(frontPageService.relationOrderRanking());
    }

    @RequestMapping("/hospitalOrderRanking")
    @ApiOperation("医院订单排行(柱状图)")
    @Permission(permission = "admin:frontPage:hospitalOrderRanking")
    public ApiResult<Object> hospitalOrderRanking(){
        return ApiResult.newSuccess(frontPageService.hospitalOrderRanking());
    }

    @RequestMapping("/birthdayToday")
    @ApiOperation("今日生日用户")
    @Permission(permission = "admin:frontPage:birthdayToday")
    public ApiResult<Object> birthdayToday(){
        return ApiResult.newSuccess(frontPageService.birthdayToday());
    }
}
